#region Copyright
/// <copyright>
/// Copyright (c) 2007 Ilia Shramko.
/// Released under the terms of the GNU General Public License.
/// </copyright>
#endregion

using System;

namespace Osh.Dvb
{
	/// <summary>
	/// Summary description for EventInformationSection.
	/// </summary>
	public class EventInformationSection : ServiceInformationSection
	{
		private ushort _serviceId;
		private byte _sectionNumber;
		private byte _lastSectionNumber;
		private ushort _transportStreamId;
		private ushort _originalNetworkId;
		private EitEvent[] _events;

		public EventInformationSection(EitReader reader) : base(reader)
		{
			_serviceId = reader.ReadUInt16BE();
			reader.SkipBytes(1);
			
			_sectionNumber = reader.ReadByte();
			_lastSectionNumber = reader.ReadByte();

			_transportStreamId = reader.ReadUInt16BE();
			_originalNetworkId = reader.ReadUInt16BE();

			reader.SkipBytes(2); // Skip segment_last_section_number & last_table_id

			_events = reader.ReadEvents(base.BodyLength - 11 - 4);

			base.ReadCrc32(reader);
		}

		public ushort ServiceId
		{
			get { return _serviceId; }
		}
		public byte SectionNumber
		{
			get { return _sectionNumber; }
		}
		public byte LastSectionNumber
		{
			get { return _lastSectionNumber; }
		}
		public ushort TransportStreamId
		{
			get { return _transportStreamId; }
		}
		public ushort OriginalNetworkId
		{
			get { return _originalNetworkId; }
		}
		public EitEvent[] Events
		{
			get { return _events; }
		}
	}
}
